package impl

import (
	v1 "gitee.com/lcc_dr/restful-api-demo/api/book/v1"
	"gitee.com/lcc_dr/restful-api-demo/apps"
	"gitee.com/lcc_dr/restful-api-demo/apps/book/impl"
	"github.com/go-playground/validator/v10"
	"github.com/infraboard/mcube/logger"
	"github.com/infraboard/mcube/logger/zap"
	"google.golang.org/grpc"
)

var GrpcImpl = &HandleBookService{}
var validate *validator.Validate

//定义 gin handler 数据结构
type HandleBookService struct {
	l logger.Logger

	svc v1.ServiceServer
}

func NewHandleHostService() *HandleBookService {

	return &HandleBookService{
		l: zap.L().Named("book"),
	}
}

// 从IOC注册中心获HostService 实例
func (h *HandleBookService) Config() {

	// h.svc = apps.HostService
	h.svc = apps.GetBookImpl(impl.AppName).(v1.ServiceServer)

}

func (H *HandleBookService) Name() string {
	return impl.AppName
}

// 从IOC注册中心获HostService 实例
func (h *HandleBookService) Registry(g *grpc.Server) {

	// h.svc = apps.HostService
	v1.RegisterServiceServer(g, h.svc)

}

// func (H *HandleBookService) Registry(g *grpc.Server) {

// }
func init() {

	apps.RegistryGrpcImpl(GrpcImpl)
}
